<template>
  <div class="wrapper">
    <swiper :options="swiperOption">
      <swiper-slide v-for="(list, index) in c_iconList" :key="index">
        <div class="icon" v-for="item in list" :key="item.id">
          <div class="imgWra">
            <img class="img" :src="item.url" alt="">
          </div>
          <p class="imgDre">{{item.des}}</p>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'icon',
  props: ['iconList'],
  data () {
    return {
      swiperOption: {}
    }
  },
  computed: {
    c_iconList () {
      let tempList = []
      this.iconList.forEach((item, index) => {
        if (item) {
          let tempIndex = Math.floor(index / 8)
          if (!tempList[tempIndex]) {
            tempList[tempIndex] = []
          }
          tempList[tempIndex].push(item)
        }
      })
      return tempList
    }
  }
}
</script>

<style lang="stylus" scoped>
  @import "~_styles/varibles.styl"
  @import "~_styles/mixins.styl"
  .wrapper >>> .swiper-container
    width: 100%
    height: 0
    overflow: hidden
    padding-bottom: 50%
  .wrapper
    .icon
      position: relative
      float: left;
      width: 25%
      height: 0
      padding-bottom: 25%
      overflow: hidden
      .imgWra
        padding: .1rem
        box-sizing: border-box
        position: absolute
        top: 0
        left: 0
        right: 0
        bottom: .44rem
        .img
          display: block
          margin: 0 auto
          height: 100%
      .imgDre
        position: absolute
        left: 0
        right: 0
        bottom: 0
        height: .44rem
        line-height: .44rem
        text-align: center
        color: $darkTextColor
        ellipsis()
</style>
